package com.cysion.study.ui.personal

import com.cysion.study.ktbox.base.BaseActivity
import com.cysion.study.ktbox.net.BaseResponseRx
import com.cysion.study.ktbox.net.ErrorHandler
import com.cysion.study.ktbox.utils.CLog
import com.cysion.study.ktbox.utils.whiteTextTheme
import com.cysion.other.color
import com.cysion.targetfun._subscribe
import com.cysion.study.uibox.bar.TopBar
import com.cysion.study.uibox.dialog.Alert
import com.cysion.study.uibox.dialog.AlertSearch
import com.cysion.study.R
import com.cysion.study.helper.UserCache
import com.cysion.study.net.ApiClient
import com.cysion.study.widget.ShowToast
import kotlinx.android.synthetic.main.activity_mytenancy_detail.*

//订单详情
class MyTenancyDetailActivity : BaseActivity() {
    override fun getLayoutId(): Int = R.layout.activity_mytenancy_detail

    override fun initView() {
        whiteTextTheme(color(R.color.main_cl))
        topbar.apply {
            setTitle("订单详情")
            setTexts("搜索", TopBar.Pos.RIGHT)
            setOnTopBarClickListener { obj, pos ->
                if (pos == TopBar.Pos.LEFT) {
                    finish()
                }else if (pos == TopBar.Pos.RIGHT) {
                    AlertSearch.search(self,""){ confirm: Int, start: String, end: String ->
                        CLog.i("@@@搜索"+start+end)

//                        getDataList(curPage,start,end)
                    }
                }
            }
        }
    }
    //加载数据
    override fun initData() {
        super.initData()

    }




    private fun getDataList(page: Int) {
        Alert.loading(self)
        ApiClient.api.getTutorOrderList(UserCache.token,"","").compose(BaseResponseRx.validateToMain())
            ._subscribe {
                _onNext {
                    Alert.close()


                }
                _onError {
                    Alert.close()
                    ShowToast(ErrorHandler.handle(it).errorMsg)

                }
            }

    }

    private fun dowith(orderId: String, type: String, reason: String) {
        Alert.loading(self)
        ApiClient.api.dowith(UserCache.token, orderId, type, reason).compose(BaseResponseRx.validateToMain())
            ._subscribe {
                _onNext {
                    Alert.close()
                    ShowToast("操作成功")

                }
                _onError {
                    Alert.close()
                    ShowToast(ErrorHandler.handle(it).errorMsg)
                }
            }

    }

    override fun closeMvp() {
    }

}
